const QiniuManager = require('./src/utils/QiniuManager')
const path = require('path')
//generate mac
const accessKey = 'gMQ9cdDqoS2LitsYNlmxX8B5WbDnBIYmlGS79QFt';
const secretKey = 'tRQaNXXQwWwrCgUpw6J3JJLo4ob6aeLbRZLJzgi7';
const localFile = "G:\\学习笔记\\vnote笔记\\webpack\\webpack初体验.md";
const key='webpack初体验.md'
const downloadPath = path.join(__dirname, key)

const manager = new QiniuManager(accessKey, secretKey, 'qiniuclouddoc')
// manager.uploadFile(key, downloadPath).then((data) => {
//   console.log('上传成功',data)
// })
//manager.deleteFile(key)
// manager.generateDownloadLink(key).then(data => {
//   console.log(data)
//   return manager.generateDownloadLink('first.md')
// }).then(data => {
//   console.log(data)
// })
//const publicBucketDomain = 'http://pv8m1mqyk.bkt.clouddn.com';

manager.downloadFile(key, downloadPath).then(() => {
  console.log('下载写入文件完毕')
})



// var options = {
//   scope: 'qiniuclouddoc',
// };
// var putPolicy = new qiniu.rs.PutPolicy(options);
// var uploadToken=putPolicy.uploadToken(mac);

// // init config class
// var config = new qiniu.conf.Config();
// // 空间对应的机房
// config.zone = qiniu.zone.Zone_z0;

// var localFile = "G:\\学习笔记\\vnote笔记\\webpack\\webpack初体验.md";
// var formUploader = new qiniu.form_up.FormUploader(config);
// var putExtra = new qiniu.form_up.PutExtra();
// var key='webpack初体验.md';
// // 文件上传
// // formUploader.putFile(uploadToken, key, localFile, putExtra, function(respErr,
// //   respBody, respInfo) {
// //   if (respErr) {
// //     throw respErr;
// //   }

// //   if (respInfo.statusCode === 200) {
// //     console.log(respBody);
// //   } else {
// //     console.log(respInfo.statusCode);
// //     console.log(respBody);
// //   }
// // });

// var bucketManager = new qiniu.rs.BucketManager(mac, config);
// var publicBucketDomain = 'http://qqv0kcrxz.hd-bkt.clouddn.com';
// // 公开空间访问链接
// var publicDownloadUrl = bucketManager.publicDownloadUrl(publicBucketDomain, key);
// console.log(publicDownloadUrl);
